var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, a) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var a in t)
              Object.prototype.hasOwnProperty.call(t, a) && (e[a] = t[a]);
          })(t, a);
      };
      return function (t, a) {
        function o() {
          this.constructor = t;
        }
        if ("function" != typeof a && null !== a)
          throw new TypeError(
            "Class extends value " + String(a) + " is not a constructor or null"
          );
        e(t, a),
          (t.prototype =
            null === a
              ? Object.create(a)
              : ((o.prototype = a.prototype), new o()));
      };
    })(),
  EstateHomeView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.remainNum = 0),
        (t.isExistHouse = !1),
        (t.fangchan_lv = 0),
        t.btn_estate_back.on(Laya.Event.CLICK, t, t.onBackPre),
        t.btn_estate_xiuxi.on(Laya.Event.CLICK, t, t.onEstateRestAction),
        t.btn_estate_gongfang.on(
          Laya.Event.CLICK,
          t,
          t.onJumpViewGongFangDidClick
        ),
        t.btn_estate_cangku.on(Laya.Event.CLICK, t, t.onJumpViewCangKuDidClick),
        t.btn_estate_kefang.on(Laya.Event.CLICK, t, t.onJumpViewKeFangDidClick),
        (t.btn_estate_cangku.visible = !1),
        (t.btn_estate_kefang.visible = !1),
        t.btn_estate_liandanfang.on(
          Laya.Event.CLICK,
          t,
          t.onJumpViewLDFDidClick
        ),
        t.btn_exp_pool.on(Laya.Event.CLICK, t, t.onJumpExpPoolDidClick),
        t.btn_estate_shufang.on(
          Laya.Event.CLICK,
          t,
          t.onJumpViewShuFangDidClick
        ),
        t.btn_estate_home.on(
          Laya.Event.CLICK,
          t,
          t.onJumpViewShuFanBuyAndSuperDidClick
        ),
        WebSocketService.addListener({
          caller: t,
          code: 1483,
          method: t.onLoadHaveRestData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1385,
          method: t.onGouMaiFangChanData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1386,
          method: t.onShengJiFangChanData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1480,
          method: t.onLoadMyHouseMessage,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1512,
          method: t.onShuFangStateData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1451,
          method: t.onLoadMyselfMoneydata,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1488,
          method: t.onLoadLookGongFangData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 6401,
          method: t.onLoadLianDanFangData,
        }),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showEstateHomeView = function (e) {
        return (
          null == this.estateHomeV && (this.estateHomeV = new t()),
          (this.estateHomeV.isExistHouse = e),
          e
            ? ((this.estateHomeV.btn_estate_home.label = "升级"),
              this.estateHomeV.dealBelongEstateType(!1))
            : ((this.estateHomeV.btn_estate_home.label = "购买"),
              this.estateHomeV.dealBelongEstateType(!0)),
          (this.estateHomeV.remainNum = 0),
          WebSocketService.send({ c: 1451 }),
          WebSocketService.send({ c: 1480 }),
          this.estateHomeV
        );
      }),
      (t.prototype.onLoadMyselfMoneydata = function (e) {
        (this.lable_my_money.text = e.data.gold),
          Laya.stage.event("GameMainView", { code: "moeny", data: e.data }),
          Laya.stage.event("HomePageView", { code: "moeny", data: e.data });
      }),
      (t.prototype.onShuFangStateData = function (e) {
        if (0 == e.code && e.data)
          if (-1 == e.data)
            LibraryRoomDialog.openLibraryDialog(this.fangchan_lv);
          else {
            var t = this.ChangeHourMinutestr(e.data);
            ToastView.toastView(
              "您正在修炼当中，不能重新设置修炼。本次修炼还需" + t
            );
          }
      }),
      (t.prototype.ChangeHourMinutestr = function (e) {
        var t = Math.floor(e / 60),
          a = Math.floor(e % 60);
        return t < 1 ? a + "分钟" : t + "小时" + a + "分钟";
      }),
      (t.prototype.dealBelongEstateType = function (e) {
        (this.btn_estate_cangku.disabled = e),
          (this.btn_estate_kefang.disabled = e),
          (this.btn_estate_shufang.disabled = e),
          (this.btn_estate_gongfang.disabled = e),
          (this.btn_estate_liandanfang.disabled = e),
          (this.btn_estate_xiuxi.disabled = e);
      }),
      (t.prototype.onGouMaiFangChanData = function (e) {
        0 == e.code &&
          (ToastView.toastView(e.data),
          (this.btn_estate_home.label = "升级"),
          WebSocketService.send({ c: 1480 }),
          WebSocketService.send({ c: 1451 }));
      }),
      (t.prototype.onShengJiFangChanData = function (e) {
        0 == e.code
          ? (ToastView.toastView(e.data),
            WebSocketService.send({ c: 1480 }),
            WebSocketService.send({ c: 1451 }))
          : ToastView.toastView(e.msg);
      }),
      (t.prototype.onEstateRestAction = function () {
        WebSocketService.send({ c: 1483 }), this.remainNum;
      }),
      (t.prototype.onLoadLookGongFangData = function (e) {
        if (0 == e.code)
          if (e.data) {
            var t = e.data.c,
              a = e.data.n,
              o = e.data.t;
            ToastView.toastView(
              a + "(ID:" + t + ")剩余修炼" + this.ChangeHourMinutestr(o)
            );
          } else PracticeRoomDialog.openLibraryDialog(this.fangchan_lv);
      }),
      (t.prototype.onJumpViewGongFangDidClick = function () {
        WebSocketService.send({ c: 1488 });
      }),
      (t.prototype.onJumpViewCangKuDidClick = function () {
        var e = PackageView.openPackageView(!1);
        e.pos(0, 40), Laya.stage.addChild(e);
      }),
      (t.prototype.onJumpViewLDFDidClick = function () {
        WebSocketService.send({ c: 6401 });
      }),
      (t.prototype.onJumpViewKeFangDidClick = function () {
        var e = DepositHeroView.openDepositView(!1);
        e.pos(0, 40), Laya.stage.addChild(e);
      }),
      (t.prototype.onJumpViewShuFangDidClick = function () {
        WebSocketService.send({ c: 1512 });
      }),
      (t.prototype.onJumpViewShuFanBuyAndSuperDidClick = function (e) {
        "购买" == e.target.label
          ? NormalDialog.showNormalDialog(
              "您是否确认花费1980金购买1级房屋(平房)",
              this,
              this.onDidGoBuyFunction
            )
          : NormalDialog.showNormalDialog(
              this.dealBuyTitle(this.fangchan_lv),
              this,
              this.onDidUpgradeFunction
            );
      }),
      (t.prototype.onDidGoBuyFunction = function () {
        WebSocketService.send({ c: 1385 });
      }),
      (t.prototype.onDidUpgradeFunction = function () {
        WebSocketService.send({ c: 1386 });
      }),
      (t.prototype.dealBuyTitle = function (e) {
        var t = "";
        return (
          0 == e
            ? (t = "您是否确认花费1980金购买1级房屋(平房)")
            : 1 == e
            ? (t = "您是否确认花费2980金升级到2级房屋(楼房)")
            : 2 == e
            ? (t = "您是否确认花费3980金升级到3级房屋(loft)")
            : 3 == e
            ? (t = "您是否确认花费4980金升级到4级房屋(别墅)")
            : 4 == e && (t = "您是否确认花费5980金升级到5级房屋(花园洋房)"),
          t
        );
      }),
      (t.prototype.onLoadHaveRestData = function (e) {
        0 == e.code
          ? (ToastView.toastView(e.data),
            this.remainNum--,
            (this.label_estate_restNum.text =
              "(" + this.remainNum + "/" + this.fangchan_lv + ")"),
            Laya.stage.event("GameMainView", "exp"),
            Laya.stage.event("HomePageView", "exp"))
          : ToastView.toastView(e.msg);
      }),
      (t.prototype.onLoadMyHouseMessage = function (e) {
        if (0 == e.code) {
          (this.label_estate_restNum.text =
            "(" + e.data.r + "/" + e.data.lvl + ")"),
            (this.label_estate_title.text = e.data.n),
            (this.remainNum = e.data.r);
          var t = e.data.lvl;
          (this.fangchan_lv = e.data.lvl),
            t >= 1
              ? ((this.btn_estate_shufang.label = t + "级书房"),
                (this.btn_estate_shufang.disabled = !1))
              : ((this.btn_estate_shufang.label = "需1级房"),
                (this.btn_estate_shufang.disabled = !0)),
            t >= 3
              ? ((this.btn_estate_gongfang.label = t - 2 + "级功房"),
                (this.btn_estate_gongfang.disabled = !1))
              : ((this.btn_estate_gongfang.label = "需3级房"),
                (this.btn_estate_gongfang.disabled = !0)),
            t >= 5
              ? ((this.btn_estate_liandanfang.label = "炼丹房"),
                (this.btn_estate_liandanfang.disabled = !1))
              : ((this.btn_estate_liandanfang.label = "需5级房"),
                (this.btn_estate_liandanfang.disabled = !0)),
            (this.btn_estate_home.visible = !0),
            1 == t
              ? (this.label_estate_title.color = "#FFFFFF")
              : 2 == t
              ? (this.label_estate_title.color = "#3CB371")
              : 3 == t
              ? (this.label_estate_title.color = "#00BFFF")
              : 4 == t
              ? (this.label_estate_title.color = "#FF00FF")
              : 5 == t &&
                ((this.label_estate_title.color = "#DC143C"),
                (this.btn_estate_home.visible = !1));
        } else {
          var a = e.msg;
          -1 != a.indexOf("没有购买房产")
            ? (this.dealBelongEstateType(!0),
              (this.btn_estate_home.label = "购买"),
              (this.btn_estate_home.visible = !0),
              ToastView.toastView(a))
            : (ToastView.toastView(a), this.onBackPre());
        }
      }),
      (t.prototype.onLoadLianDanFangData = function (e) {
        console.log(e.data),
          e.data
            ? Alert.openText(
                e.data.n + "正在修炼，修炼剩余时间" + e.data.t + "分钟"
              )
            : DragonChemistDialog.open();
      }),
      (t.prototype.onJumpExpPoolDidClick = function () {
        ExperiencePool.showExpPoolView();
      }),
      (t.prototype.onBackPre = function () {
        this.removeSelf();
      }),
      t
    );
  })(ui.Estatemarket.EstateHomeViewUI);
